package com.crm.sys.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.crm.base.dao.BaseDao;
import com.crm.sys.dao.SysMessageDao;
import com.crm.sys.model.Role;
import com.crm.sys.model.SysMessage;
import com.crm.sys.model.UserHistoryMessage;
@Repository("sysMessageDao")
public class SysMessageDaoImpl extends BaseDao implements SysMessageDao {

	private static final String MAPPER_NAMESAPCE = "SysMessageMapper.";
	@Override
	public List<SysMessage> getMessageList(SysMessage ms) {
		return selectList(MAPPER_NAMESAPCE+"selectMessage", ms);
	}

	@Override
	public int getMessageCount(SysMessage ms) {
		return selectOne(MAPPER_NAMESAPCE+"selectMessageCount", ms);
	}

	@Override
	public int insertMessage(SysMessage ms) {
		return insert(MAPPER_NAMESAPCE+"insertMessage", ms);
	}

	@Override
	public int updateMessageState(SysMessage ms) {
		return update(MAPPER_NAMESAPCE+"updateMessage", ms);
	}

	@Override
	public List<UserHistoryMessage> getMessageList(UserHistoryMessage ms) {
		List<UserHistoryMessage> list = selectList(MAPPER_NAMESAPCE+"getHistoryMessageList",ms);
		if (list != null && list.size()>0) {
			list.get(0).setTotalResults((Integer)selectOne(MAPPER_NAMESAPCE+"getHistoryMessageCount", ms));
		}
		return list;
	}

}
